package cn.lg.soar.common.model;

import cn.lg.soar.common.util.jackson.serializer.LongToNumberSerializer;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.annotations.ApiModelProperty;

/**
 * 统一http响应结果
 * @author luguoxiang
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
public interface IHttpResult<T> {

    /**
     * 获取数据
     * @return
     */
    @JsonInclude
    @ApiModelProperty(value = "数据")
    T getData();

    /**
     * 获取错误码
     * @return
     */
    @JsonInclude
    @ApiModelProperty(value = "错误码")
    String getCode();

    /**
     * 获取信息
     * @return
     */
    @JsonInclude
    @ApiModelProperty(value = "信息")
    String getMsg();

    /**
     * 获取时间戳
     * @return
     */
    @JsonInclude
    @JsonSerialize(using= LongToNumberSerializer.class)
    @ApiModelProperty(value = "时间戳")
    default Long getTs() {
        return System.currentTimeMillis();
    }

}
